#!/bin/bash

# 调优进程调度延迟：设置迁移成本阈值
CONFIG_FILE="/etc/sysctl.conf"
PARAM="kernel.sched_migration_cost_ns"
VALUE="5000000"

# 清理旧配置并应用新设置
sed -i "/^${PARAM}\s*=/d" "$CONFIG_FILE"
echo "${PARAM}=${VALUE}" >> "$CONFIG_FILE"

# 立即生效配置
sysctl -p "$CONFIG_FILE" >/dev/null

# 验证结果
echo "配置已更新："
grep "$PARAM" "$CONFIG_FILE"
sysctl "$PARAM"